package kr.hkit.androidcomplete01.ch07;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Bundle;
import android.view.View;

public class Primitive1 extends Activity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		setContentView(new MyView(this));
	}
	
	class MyView extends View {
		
		private Paint paint;
		private Rect r;
		private RectF rect;
		
		public MyView(Context context) { //우린 하나만 해여
			super(context);
			paint = new Paint(Paint.ANTI_ALIAS_FLAG); //안티엘리어싱 기능있음
			r = new Rect(200, 0, 300, 100);
			rect = new RectF(200L, 120L, 300L, 220L);
		}
		
		@Override
		protected void onDraw(Canvas canvas) {
			super.onDraw(canvas);
			
			canvas.drawColor(Color.LTGRAY);
			canvas.drawPoint(10, 10, paint);
			
			paint.setColor(Color.BLUE); //디폴트는 블랙
			canvas.drawLine(20, 10, 200, 50, paint);
			
			paint.setColor(Color.RED);
			canvas.drawCircle(100, 90, 50, paint);
			
			paint.setColor(0x800000ff);
			canvas.drawRect(10, 100, 200, 170, paint);
			
			paint.setColor(0x80ff0000);
			canvas.drawRect(r, paint);
			
			paint.setColor(0x80ff0000);
			canvas.drawRect(rect, paint);
			
			paint.setColor(Color.BLACK);
			canvas.drawText("Canvas Text out", 10, 200, paint);
			
		}
		
	}

}
